package com.zdtech.action;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionSupport;
import com.zdtech.entity.TUser;
import com.zdtech.service.BaseSerive;
import com.zdtech.util.StringUtil;
@Controller
public class RegistAction extends ActionSupport{
	
	private String username;
	private String pwd;
	private String repwd;
	private String name;
	private String tel;
	private String addre;
	private String birth;
	private String purview;
	@Resource
	private BaseSerive baseSerive;
	
	public String execute() throws Exception {
		if(StringUtil.isEmpty(username)){
			if(StringUtil.isEmpty(pwd)){
				if(StringUtil.isEmpty(repwd)){
					if(StringUtil.isEmpty(purview)){
						if(repwd!=pwd){
							TUser u = new TUser();
							u.setUser(username);
							u.setPwd(pwd);
							u.setName(name);
							u.setTel(tel);
							u.setAddre(addre);
							u.setBirth(birth);
							u.setPurview(Integer.parseInt(purview));
							baseSerive.insertUser(u);
							return Action.SUCCESS;
						}else{
							System.out.println("pwd unequal");
						}
					}else{
						System.out.println("purview empty");
					}
				}else{
					System.out.println("repwd empty");
				}
			}else{
				System.out.println("pwd empty");
			}
		}else{
			System.out.println("username empty");
		}
		return Action.ERROR;
	}
	public String getUsername() {
		return username;
	}
	public void setUsername(String username) {
		this.username = username;
	}
	public String getPwd() {
		return pwd;
	}
	public void setPwd(String pwd) {
		this.pwd = pwd;
	}
	public String getRepwd() {
		return repwd;
	}
	public void setRepwd(String repwd) {
		this.repwd = repwd;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getTel() {
		return tel;
	}
	public void setTel(String tel) {
		this.tel = tel;
	}
	public String getAddre() {
		return addre;
	}
	public void setAddre(String addre) {
		this.addre = addre;
	}
	public String getBirth() {
		return birth;
	}
	public void setBirth(String birth) {
		this.birth = birth;
	}
	public String getPurview() {
		return purview;
	}
	public void setPurview(String purview) {
		this.purview = purview;
	}
	
}
